<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('所有部门统计分析')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>岗位名称：</label>
                            <input type="text" name="postName" placeholder="请输入关键字"/>
                        </li>
                        <li>
                            <label>开始时间：</label>
                            <input type="text" class="time-input" placeholder="" name="params[beginTime]"/>
                        </li>
                        <li>
                            <label>结束时间：</label>
                            <input type="text" class="time-input" placeholder="" name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table ">

            <div class="col-sm-6 table-striped">
                <table id="bootstrap-table"></table>
            </div>
            <div class="col-sm-6"  style="height: 100%; margin: 0;height: 500px">
                <div id="container" style="height: 100%"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
<th:block th:include="include :: footer" />
<script th:inline="javascript">

    var prefix = ctx + "wstudy/summary";
    let str = [
        {value: 1048, name: '搜索引擎'},
        {value: 735, name: '直接访问'},
        {value: 580, name: '邮件营销'},
        {value: 484, name: '联盟广告'},
    ]
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};
    var option;

    var datas = []
    $(function() {
        var options = {
            url: prefix + "/queryPostNum",
            modalName: "统计分析",
            onLoadSuccess: function(){  //加载成功时执行
                let obj = arguments[0];
                // datas=[]
                // $.each(obj.rows,function (index,item) {
                //     datas.push({"name":item.postName,"value":item.needNum})
                // })
                // setData(datas)
            },
            columns: [{
                checkbox: true
            },
                {
                    field: 'postId',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'postName',
                    title: '岗位名称'
                },
                {
                    field: 'needNum',
                    title: '拟招录人数'
                },
                {
                    field: 'params.applyNum',
                    title: '申请人次'
                },
                {
                    field: 'params.failedNum',
                    title: '审批不通过人次'
                },
                {
                    field: 'params.disAgreeNum',
                    title: '拒绝Offer人次'
                },
                {
                    field: 'actuals',
                    title: '实际录用人数'
                },
            ]
        };
        $.table.init(options);

    });

let list = [[${list}]]
$.each(list,function (index,item) {
    datas.push({"name":item.postName,"value":item.needNum})
})
setData(datas)
function setData(data) {
    option = {
        title: {
            text: '招录人数',
            subtext: '勤工俭学岗位招录',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left',
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: '50%',
                data:data,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    if (option && typeof option === 'object') {
        myChart.setOption(option);
    }
}
</script>
</body>
</html>